package com.imooc.mall.model.config;

import com.imooc.mall.model.filter.AdminFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

@Configuration    //声明配置文件，如。xml文件
public class AdminFilterConfig {

    @Bean
    public AdminFilter adminFilter(){
        return new AdminFilter();
    }

    @Bean("adminFilterConf")
    public FilterRegistrationBean adminFilterConfig(){
        FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
        bean.setFilter(adminFilter());
        bean.addUrlPatterns("/admin/category/*");
        bean.addUrlPatterns("/admin/product/*");
        bean.addUrlPatterns("/admin/order/*");
        bean.setName("adminFilterConf");
        return bean;
    }


}
